﻿@model IEnumerable<WebVideo.EntitySupportAdmin>
<script type="text/javascript">
    function deletehis(id) {
        var c = confirm('Continue delete?');
        if (c) $('#hs'+id).fadeOut(function () {
            var getURL = '@Url.Action("Delete", "SupportAdmin")';

            $.get(getURL, { "id": id }, function (data) {
                if (data == "error") //error
                {
                    $('#nofError').show();
                    $('#nofSuccess').hide();
                    $('#msgNofError').text("Cannot Delete Record");
                }
                else {
                    jQuery(this).remove();
                    $('#nofError').hide();
                    $('#nofSuccess').show();
                    $('#msgNofSuccess').text("Delete Record Ok");
                }
            });
        });
        return false;
    }
    function Clearn() {
        var c = confirm('Continue delete?');
        var UserName = '@ViewBag.UserName';
        if (c){
            var getURL = '@Url.Action("DeleteAll", "SupportAdmin")';

            $.get(getURL, { "UserName": UserName }, function (data) {
                if (data == "error") //error
                {
                    $('#nofError').show();
                    $('#nofSuccess').hide();
                    $('#msgNofError').text("Cannot Delete");
                   
                }
                else {
                    $('#nofError').hide();
                    $('#nofSuccess').show();
                    $('#msgNofSuccess').text("Delete Ok");
                    $('div#history').html(" ");
                }
            });
        };
        return false;
    }
   
</script>
<div class="contenttitle radiusbottom0">
        <h2 class="table"><span>Lịch sử</span></h2>
    </div>
    <!--contenttitle-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="dyntable">
        <colgroup>
            <col class="con0" />
            <col class="con1" />
            <col class="con0" />
            <col class="con1" />
        </colgroup>
        <thead>
            <tr>
                <th class="head0">STT</th>
                <th class="head1">UserName</th>
                <th class="head0">Contents</th>
                <th class="head1">Date</th>
                <th class="head0"> <a href ="#" onclick="return Clearn();">Xóa toàn bộ lịch sử đã trả lời</a></th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                  <th class="head0">STT</th>
                <th class="head1">UserName</th>
                <th class="head0">Contents</th>
                <th class="head1">Date</th>
                <th class="head0"></th>
            </tr>
        </tfoot>
        <tbody>
            @{
                int i = 0;
                foreach (var item in Model)
                {
                    i++;
                    string idd = "hs"+item.Id.ToString();
                <tr class="gradeX" id="@idd">
                    <td>
                        <label>@i.ToString()</label>
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.UserName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelitem => item.Contents)
                    </td>
                     <td>
                        @Html.DisplayFor(modelitem => item.Date)
                    </td>
                    <td class ="eddelete">
                        @Html.ActionLink(" ", "Insert", new { UserName = @item.UserName, Id = @item.Id }, new { @class = "edit", title="Trả lời" })
                        <a href="#" class="delete" title="Delete" onclick="return deletehis('@item.Id');"></a>
                    </td>
                </tr> 
                }                      
            }
        </tbody>
    </table>